class AdminController < ApplicationController
  layout "words"

  def login       
      session[:user] = nil 
      
      if request.post? 
        user = User.authenticate(params[:username], params[:password])
        if user 
        session[:user] = user.id 
        redirect_to (:controller => "words", :action => "index")
        else 
        flash.now[:notice] = "错误的用户名或密码" 
      end    
    end
  end

  def logout
    session[:user] = nil 
    redirect_to :controller => "words", :action => "index" 
  end

end
